﻿<?xml version="1.0" encoding="utf-8" ?>
<FieldTypes>
  <FieldType>
    <Field Name="TypeName">ReadUnreadMarksDataField</Field>
    <Field Name="TypeDisplayName">Read or Unread marker field</Field>
    <Field Name="ParentType">Note</Field>
    <Field Name="TypeShortDescription">Read and unread marks for SharePoint list items</Field>
    <Field Name="FieldTypeClass">Version3.SharePoint.ReadUnreadMarksDataField,Version3.ListItemReadUnreadSiteColumn, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d055e77f5fe6a467</Field>
    <Field Name="FieldEditorUserControl">/_controltemplates/ReadUnreadMarksDataFieldPropertyEditor.ascx</Field>
    <Field Name="DisplaySize">5</Field>
    <Field Name="Sortable">FALSE</Field>
    <Field Name="Filterable">FALSE</Field>
    <Field Name="UserCreatable">TRUE</Field>
    <Field Name="ShowInListCreate">TRUE</Field>
    <Field Name="ShowInSurveyCreate">FALSE</Field>
    <Field Name="ShowInDocumentLibraryCreate">FALSE</Field>
    <Field Name="ShowInColumnTemplateCreate">FALSE</Field>
    <PropertySchema>
      <Fields>
        <Field Name="ColumnRenderMode" Hidden="TRUE" DisplayName="ColumnRenderMode" Type="Text" MaxLength="255">
          <Default></Default>
        </Field>
        <Field Name="ClearReadMarksOnUpdate" Hidden="TRUE" DisplayName="ClearReadMarksOnUpdate" Type="Text" MaxLength="255">
          <Default></Default>
        </Field>
        <Field Name="ShowInlineEditingTools" Hidden="TRUE" DisplayName="ShowInlineEditingTools" Type="Text" MaxLength="255">
          <Default></Default>
        </Field>
        <Field Name="WriteDirect" Hidden="TRUE" DisplayName="WriteDirect" Type="Text" MaxLength="255">
          <Default></Default>
        </Field>
        <Field Name="VisibleOnForm" Hidden="TRUE" DisplayName="VisibleOnForm" Type="Text" MaxLength="255">
          <Default></Default>
        </Field>
        <Field Name="ReadImageURL" Hidden="TRUE" DisplayName="ReadImageURL" Type="Text" MaxLength="255">
          <Default></Default>
        </Field>
        <Field Name="UnreadImageURL" Hidden="TRUE" DisplayName="UnreadImageURL" Type="Text" MaxLength="255">
          <Default></Default>
        </Field>
        <Field Name="UnreadHTMLColor" Hidden="TRUE" DisplayName="UnreadHTMLColor" Type="Text" MaxLength="255">
          <Default></Default>
        </Field>
      </Fields>
    </PropertySchema>
    <RenderPattern Name="HeaderPattern">
      <HTML>
        <![CDATA[<div style="width: 100%; position: relative; left: 0; top: 0;">]]>
      </HTML>
      <HTML>
        <!--Start column javascript functions -->
        <![CDATA[<script type="text/javascript"> ]]>
        <!--Start setFontOnTagAndAllChildTags -->
        <![CDATA[function setFontOnTagAndAllChildTags(parentTag, fontValue){]]>
        <![CDATA[try{parentTag.style.fontWeight = fontValue;}catch(e){}]]>
        <![CDATA[var childCount = parentTag.childNodes.length;]]>
        <![CDATA[for(var i=0; i< childCount ; i++)]]>
        <![CDATA[{setFontOnTagAndAllChildTags(parentTag.childNodes[i],fontValue);}}]]>
        <!--Start setColorOnTagAndAllChildTags -->
        <![CDATA[function setColorOnTagAndAllChildTags(parentTag, colorValue){]]>
        <![CDATA[try{parentTag.style.color = colorValue;parentTag.style.fontWeight = "bolder";}catch(e){}]]>
        <![CDATA[var childCount = parentTag.childNodes.length;]]>
        <![CDATA[for(var i=0; i< childCount ; i++)]]>
        <![CDATA[{setColorOnTagAndAllChildTags(parentTag.childNodes[i],colorValue);}}]]>
        <!--Start markRowAsUnread -->
        <![CDATA[function markRowAsUnread(divMarkerId, rowColor){]]>
        <![CDATA[var divTag = document.getElementById(divMarkerId);]]>
        <![CDATA[var divRow = divTag.parentNode.parentNode;]]>
        <![CDATA[var rowColor ="]]>
      </HTML>
      <Property Select="UnreadHTMLColor" />
      <HTML>
        <![CDATA[";]]>
        <![CDATA[if (rowColor != "") {setColorOnTagAndAllChildTags(divRow,rowColor);}else{]]>
        <![CDATA[setFontOnTagAndAllChildTags(divRow,"bolder");}}]]>
        <!--Start markRowAsRead -->
        <![CDATA[function markRowAsRead(divMarkerId){]]>
        <![CDATA[var divTag = document.getElementById(divMarkerId);]]>
        <![CDATA[var divRow = divTag.parentNode.parentNode;]]>
        <![CDATA[setFontOnTagAndAllChildTags(divRow,"normal");}]]>
        <!--Start inline_ReadUnReadCheckBox_onclick -->
        <!--Start inline_MarkReadOrUnread -->
        <![CDATA[function MarkItemReadOrUnread(readMark,cBox,itemID,divMarkerId){]]>
        <![CDATA[var requestURL = ctx.HttpRoot + "/_Layouts/VERSION3/LazyReadUnReadUpdate.aspx";]]>
        <![CDATA[requestURL += "?iID=" + itemID;]]>
        <![CDATA[requestURL += "&lID=" + ctx.listName;]]>
        <![CDATA[requestURL += "&nValue=" + readMark;]]>
        <![CDATA[requestURL += "&pName=]]>
      </HTML>
      <Property Select="Name" />
      <HTML>
        <![CDATA[";requestURL += "&mWD=]]>
      </HTML>
      <Property Select="WriteDirect" />
      <HTML>
        <![CDATA[";]]>
        <!--<![CDATA[window.open(requestURL);}]]>-->
        <![CDATA[var httpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("MSXML2.XMLHTTP.3.0");]]>
        <![CDATA[httpRequest.onreadystatechange = function(){]]>
        <![CDATA[if (4 ==httpRequest.readyState){]]>
        <![CDATA[if ("read" == httpRequest.responseText ){if(null != cBox)cBox.checked=true;markRowAsRead(divMarkerId);}]]>
        <![CDATA[else{if ("unread" == httpRequest.responseText ){if(null != cBox)cBox.checked=false;markRowAsUnread(divMarkerId);}else{if(null != cBox)cBox.checked=!cBox.checked;}}]]>
        <![CDATA[}};httpRequest.open("GET", requestURL, true);httpRequest.send(null);}]]>
        <![CDATA[</script >]]>
      </HTML>
      <HTML>
        <![CDATA[</div>]]>
      </HTML>
    </RenderPattern>
    <RenderPattern Name="DisplayPattern">
      <SetVar Name="readColDivCounter">
        <Counter/>
      </SetVar>
      <SetVar Name="currentColumnIsRead" Scope="Request" Value="0"/>
      <!--This table is named and allows our javascript for this row to locate all related elements-->
      <HTML><![CDATA[<table style="width: 100%;" cellpadding="0" border="0" cellspacing="0"  id="readMarkerColumn]]></HTML>
      <GetVar Name="readColDivCounter"/>
      <HTML><![CDATA[" ><tr>]]></HTML>
      <HTML><![CDATA[<td>]]></HTML>
      <Switch>
        <Expr>
          <Property Select="ColumnRenderMode" />
        </Expr>
        <Case Value="BoldDisplay">
          <IfSubString>
            <Expr1>
              <HTML><![CDATA[.]]></HTML>
              <UserID AllowAnonymous = "FALSE"/>
              <HTML><![CDATA[.]]></HTML>
            </Expr1>
            <Expr2>
              <Column/>
            </Expr2>
            <Then>
              <SetVar Name="currentColumnIsRead" Scope="Request" Value="1"/>
              <!--ReadMark has been found-->
              <HTML><![CDATA[<script type="text/javascript"> ]]></HTML>
              <HTML><![CDATA[markRowAsRead("readMarkerColumn]]></HTML>
              <HTML>
                <GetVar Name="readColDivCounter"/>
              </HTML>
              <HTML><![CDATA[");]]></HTML>
              <HTML><![CDATA[</script >]]></HTML>
            </Then>
            <Else>
              <SetVar Name="currentColumnIsRead"  Scope="Request" Value="0"/>
              <!--No read Mark has been found-->
              <HTML><![CDATA[<script type="text/javascript"> ]]></HTML>
              <HTML><![CDATA[markRowAsUnread("readMarkerColumn]]></HTML>
              <HTML>
                <GetVar Name="readColDivCounter"/>
              </HTML>
              <HTML><![CDATA[");]]></HTML>
              <HTML><![CDATA[</script >]]></HTML>
            </Else>
          </IfSubString>
        </Case>
        <!--In Iconic mode we end up here-->
        <Case Value="Iconic">
          <IfSubString>
            <Expr1>
              <HTML><![CDATA[.]]></HTML>
              <UserID AllowAnonymous = "FALSE"/>
              <HTML><![CDATA[.]]></HTML>
            </Expr1>
            <Expr2>
              <Column/>
            </Expr2>
            <Then>
              <SetVar Name="currentColumnIsRead" Scope="Request" Value="1"/>
              <HTML><![CDATA[<img style="vertical-Align:middle;" width="16" height = "16" border="0" src="]]></HTML>
              <Property Select="ReadImageURL" />
              <HTML><![CDATA[">]]></HTML>
            </Then>
            <Else>
              <SetVar Name="currentColumnIsRead" Scope="Request" Value="0"/>
              <HTML><![CDATA[<img style="vertical-Align:middle;" width="16" height = "16" border="0" src="]]></HTML>
              <Property Select="UnreadImageURL" />
              <HTML><![CDATA[">]]></HTML>
            </Else>
          </IfSubString>
        </Case>
        <Default>
          <!--Never called unless the column settings are corrupted-->
          <IfSubString>
            <Expr1>
              <HTML><![CDATA[.]]></HTML>
              <UserID AllowAnonymous = "FALSE"/>
              <HTML><![CDATA[.]]></HTML>
            </Expr1>
            <Expr2>
              <Column/>
            </Expr2>
            <Then>
              <HTML><![CDATA[Dont bother, you have already read this]]></HTML>
            </Then>
            <Else>
              <HTML><![CDATA[You should read this, it migh tbe interesting]]></HTML>
            </Else>
          </IfSubString>
        </Default>
      </Switch>
      <HTML><![CDATA[</td>]]></HTML>
      <!--Render the inline check box for setting or clearing the read mark-->
      <Switch>
        <Expr>
          <Property Select="ShowInlineEditingTools" />
        </Expr>
        <Case Value="TRUE">

          <IfEqual>
            <Expr1>
              <GetVar Name="ReadUnreadSummaryHack"/>
            </Expr1>
            <Expr2>1</Expr2>
            <Then>
              <!--Dont do antying because we dont allow this in the summary-->
            </Then>
            <Else>
              <IfEqual>
                <Expr1>
                  <LookupColumn Name="FSObjType"/>
                </Expr1>
                <Expr2>1</Expr2>
                <Then>
                  <!--Render the inline menu bar for checking or unchecking all  child items style="width:26px;"  -->
                  <HTML><![CDATA[<td  valign="middle" align="center" >]]></HTML>
                  <HTML>
                    <![CDATA[<span style="display: none">]]>
                    <![CDATA[<menu type="ServerMenu" compactmode="true" id="inlineReadUnReadMenu_]]>
                  </HTML>
                  <HTML>
                    <GetVar Name="readColDivCounter"/>
                  </HTML>
                  <HTML>
                    <![CDATA[" >]]>
                    <![CDATA[<ie:menuitem type="option" menugroupid="100" iconSrc="/_layouts/images/checkall.gif" text="Mark all read" id="inlineMarkAllRead_ ]]>
                  </HTML>
                  <HTML>
                    <GetVar Name="readColDivCounter"/>
                  </HTML>
                  <HTML>
                    <![CDATA[" onmenuclick="javascript:MarkItemReadOrUnread(true,null,]]>
                  </HTML>
                  <Column Name="ID"/>
                  <HTML>
                    <![CDATA[,'readMarkerColumn]]>
                  </HTML>
                  <HTML>
                    <GetVar Name="readColDivCounter"/>
                  </HTML>
                  <HTML>
                    <![CDATA[');" description="Mark all items and sub items and folders in this folder as read" ></ie:menuitem>]]>
                    <![CDATA[<ie:menuitem type="option" menugroupid="100" iconSrc="/_layouts/images/unchecka.gif" text="Mark all unread" id="inlineMarkAllUnread_ ]]>
                  </HTML>
                  <HTML>
                    <GetVar Name="readColDivCounter"/>
                  </HTML>
                  <HTML>
                    <![CDATA[" onmenuclick="javascript:MarkItemReadOrUnread(false,null,]]>
                  </HTML>
                  <Column Name="ID"/>
                  <HTML>
                    <![CDATA[,'readMarkerColumn]]>
                  </HTML>
                  <HTML>
                    <GetVar Name="readColDivCounter"/>
                  </HTML>
                  <HTML>
                    <![CDATA[');" description="Mark all items and sub items and folders in this folder as unread"></ie:menuitem>]]>
                    <![CDATA[</menu></span>]]>
                  </HTML>
                  <!-- Ok now render the tag we need for the folder to appear in the list _layouts/images/existinglocations.gif -->
                  <HTML>
                    <![CDATA[<span title="Folder marking menu">]]>
                    <![CDATA[<div id="inlineReadUnReadMenu_T_]]>
                  </HTML>
                  <HTML>
                    <GetVar Name="readColDivCounter"/>
                  </HTML>
                  <HTML>
                    <![CDATA[ oncontextmenu="this.click(); return false;" nowrap="nowrap"  ]]>
                    <![CDATA[ onclick="javascript:MMU_Open(byid('inlineReadUnReadMenu_]]>
                  </HTML>
                  <HTML>
                    <GetVar Name="readColDivCounter"/>
                  </HTML>
                  <HTML>
                    <![CDATA['), MMU_GetMenuFromClientId('inlineReadUnReadMenu_A_]]>
                  </HTML>
                  <HTML>
                    <GetVar Name="readColDivCounter"/>
                  </HTML>
                  <HTML>
                    <![CDATA['),event,false, null, 0);" ]]>
                    <![CDATA[ foa="MMU_GetMenuFromClientId('inlineReadUnReadMenu_A_]]>
                  </HTML>
                  <HTML>
                    <GetVar Name="readColDivCounter"/>
                  </HTML>
                  <HTML>
                    <![CDATA[')" >]]>
                  </HTML>
                  <HTML>
                    <![CDATA[<a id="inlineReadUnReadMenu_A_]]>
                  </HTML>
                  <HTML>
                    <GetVar Name="readColDivCounter"/>
                  </HTML>
                  <HTML>
                    <![CDATA[" accesskey="L"  href="#" style="cursor: hand;white-space: nowrap;" ]]>
                    <![CDATA[ oncontextmenu="this.click(); return false;"  ]]>
                    <![CDATA[ onclick="javascript:MMU_Open(byid('inlineReadUnReadMenu_]]>
                  </HTML>
                  <HTML>
                    <GetVar Name="readColDivCounter"/>
                  </HTML>
                  <HTML>
                    <![CDATA['), MMU_GetMenuFromClientId('inlineReadUnReadMenu_A_]]>
                  </HTML>
                  <HTML>
                    <GetVar Name="readColDivCounter"/>
                  </HTML>
                  <HTML>
                    <![CDATA['),event,false, null, 0);"  ]]>
                  </HTML>
                  <HTML>
                    <![CDATA[><img  width="16" height = "16" border="0" src="/_layouts/images/existinglocations.gif" alt="Folder marking menu" /></a></div></span>]]>
                  </HTML>
                  <!-- End of folder rendering -->
                </Then>
                <Else>
                  <HTML>
                    <![CDATA[<td valign="middle" align="center" ><input type="checkbox" ]]>
                  </HTML>
                  <Switch>
                    <Expr>
                      <GetVar Scope="Request" Name="currentColumnIsRead"/>
                    </Expr>
                    <Case Value="1">
                      <HTML>
                        <![CDATA[ checked="checked" ]]>
                      </HTML>
                    </Case>
                    <Default>
                    </Default>
                  </Switch>
                  <HTML>
                    <![CDATA[" onclick="javascript:MarkItemReadOrUnread(this.checked,this,]]>
                  </HTML>
                  <Column Name="ID"/>
                  <HTML>
                    <![CDATA[,'readMarkerColumn]]>
                  </HTML>
                  <HTML>
                    <GetVar Name="readColDivCounter"/>
                  </HTML>
                  <HTML>
                    <![CDATA[');" id="inlineReadUnReadCheckBox_]]>
                  </HTML>
                  <Column Name="ID"/>
                  <HTML>
                    <![CDATA[" />]]>
                  </HTML>
                </Else>
              </IfEqual>
            </Else>
          </IfEqual>
        </Case>
        <Default>
        </Default>

      </Switch>
      <HTML><![CDATA[</td><td>]]></HTML>
      <HTML><![CDATA[</td></tr></table>]]></HTML>
    </RenderPattern>
  </FieldType>
</FieldTypes>
